module Tribonacci where

tribonacci :: Num a => (a, a, a) -> Int -> [a]
tribonacci (a, b, c) n = take n $ [a, b, c] ++ f (a, b, c)

f :: Num a => (a, a, a) -> [a]
f(a, b, c) = d : f (b, c, d)
    where d = a + b + c
          
-- after solution

tribonacci2 :: Num a => (a, a, a) -> Int -> [a]
tribonacci2 (a, b, c) 0 = []
tribonacci2 (a, b, c) n = a : tribonacci (b,c,a+b+c) (n-1)
